#!/bin/bash
echo "start" >> /home/nvidia/dataagentbin/log.txt 2>&1
current_time=`date +"%Y-%m-%d %H:%M:%S"`
echo $current_time >> /home/nvidia/dataagentbin/log.txt 2>&1
sleep 5s
export GLOG_log_dir=$GLOG_log_dir:/apollo/data/log
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/nvidia/dataagentbin:/apollo/lib
echo $LD_LIBRARY_PATH >> /home/nvidia/dataagentbin/log.txt 2>&1
while true; do
    count=$(ps -ef | grep -w "dataagent" | grep -v "grep" | wc -l)
    echo $count >> /home/nvidia/dataagentbin/log.txt 2>&1
    if [ $count -eq 0 ]; then
        echo "datagent start" >> /home/nvidia/dataagentbin/log.txt 2>&1
	/home/nvidia/dataagentbin/dataagent /home/nvidia/dataagentbin/config.json >> /home/nvidia/dataagentbin/log.txt 2>&1
	echo "dataagent end" >> /home/nvidia/dataagentbin/log.txt 2>&1
    fi
    sleep 5
done
